package com.cmwa.solution.utils.cached.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cmwa.solution.base.controller.BaseController;
import com.cmwa.solution.exception.CachedException;
import com.cmwa.solution.sys.client.ClientManager;
import com.cmwa.solution.utils.Constant;
import com.cmwa.solution.utils.cached.MenuCached;
import com.cmwa.solution.utils.cached.service.ShareCachedService;
import com.cmwa.solution.utils.spring.ContextHolderUtil;

@Controller
@RequestMapping("utils/cached/shareCached")
public class ShareCachedController extends BaseController {
	
	@Resource(name="shareCachedService")
	private ShareCachedService shareCachedService;
	
	@Resource
	private MenuCached menuCached;
	
	/**
	 * 刷新公共缓存
	 * @return
	 * @throws CachedException
	 */
	@RequestMapping("refreshShareCached")
	public String refreshShareCached() throws CachedException{
		shareCachedService.loadMappingCached();
		
		ClientManager.getInstance().clearAllClientData();
		ContextHolderUtil.getSession().removeAttribute(Constant.solution_MENU_CACHE);
		menuCached.loadAllMenuCached();
		
		return redirectSuccess();
	}

}
